<?php
namespace app\common\logic;

use app\common\component\user\UserService;
use app\common\component\user\UserValidate;
use app\common\component\user_vip\UserVipService;

class User {
	public function register($post) {
		$resultUserValidate = (new UserValidate) -> create($post);
		if($resultUserValidate['code'] !== 0) {
			echo '<meta charset="utf-8"><script>alert("' . $resultUserValidate['message'] . '!");window.history.go(-1);</script>';exit;
		}

		$registerUser = (new UserService) -> create($post);

		if($registerUser['code'] !== 0) {
			echo '<meta charset="utf-8"><script>alert("' . $registerUser['message'] . '!");window.history.go(-1);</script>';exit;
		}

		return $registerUser;
	}

	public function register2($post) {
		$resultUserValidate = (new UserValidate) -> create($post);
		if($resultUserValidate['code'] !== 0) {
			return $resultUserValidate;
		}

		$registerUser = (new UserService) -> create($post);

		if($registerUser['code'] !== 0) {
			return $registerUser;
		}

		return $registerUser;
	}
}
?>